<template>
	<view class="center">
		<u-toast ref="uToast" />
		<view class="center_top" :style="{'background-image': 'url(' + avatar + ')',backgroundSize: '100%' }">
			<view class="mask"></view>
		</view>
		<view class="center_box_bg">
			<view class="profily">
				<view class="base">
					<view class="profily_header" :style="{'background-image': 'url(' + avatar + ')',backgroundSize: '100%' }">
					</view>
					<text>{{nickname}}</text>
					<image src="../../static/fumou-center-template/setting.png" mode="" @tap="gotoseeting"></image>
				</view>
				<view class="order_status">
					<view class="status" v-for="(item,index) in status" :key="index" @click="navtoorder(item.key)">
						<view style="width: 25px;height:25px;position: relative;margin: 10rpx auto;">
						<image class="icon" :src="item.url" mode="aspectFill">
						</image>
						<u-badge :count="badgelist[index]" type="error" :is-center="true" v-if="index!=3"></u-badge>
						</view>
						<text>{{item.name}}</text>
					</view>
				</view>
			</view>
			<view class="baiban">

			</view>
			<view class="center_menu">
				<view class="menu_item" v-for="(item,index) in menus" :key="index" @click="gomenu(item.key)">
					<image :src="item.icon" mode="aspectFill"></image>
					<text>{{item.name}}</text>
				</view>
			</view>
		</view>
		<u-popup v-model="show" mode="bottom" height='50%' :closeable="isclose" close-icon-pos="top-right" @close='closepop'> 
			<view style="margin-top: 60rpx;">
				<textarea v-model="adviceparam.advice" placeholder="请输入反馈意见" height="90%"  maxlength="-1" style="height: 460rpx;"/>
				<u-button type="success" style="margin-top: auto;" @click='submit'>提交</u-button>
			</view>
				</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				adviceparam:{
					advice:'',
					useraccount:''
				},
				isclose:true,
				show:false,
				badgelist:[],
				account:'',
				// avatar:'../../static/fumou-center-template/header.jpg',
				avatar:'',
				// background: url('../../static/fumou-center-template/header.jpg');
				// background-size: 100%;
				nickname:'',
				status: [{
						key: 0,
						name: '待接单',
						url: '../../static/person/wait.png'
					},
					{
						key: 1,
						name: '进行中',
						url: '../../static/person/ing.png'
					},
					{
						key: 2,
						name: '待评价',
						url: '../../static/fumou-center-template/3.png'
					},
					{
						key: 3,
						name: '全部订单',
						url: '../../static/fumou-center-template/4.png'
					}
				],
				menus: [
					{
						name: '点过的菜',
						icon: '../../static/fumou-center-template/6.png',
						key: 1,
					},
					{
						name: '我的评价',
						icon: '../../static/fumou-center-template/7.png',
						key: 2,
					}
					,
					// {
					// 	name: '',
					// 	icon: '../../static/fumou-center-template/8.png',
					// 	key: 4,
					// },
					{
						name: '意见反馈',
						icon: '../../static/fumou-center-template/9.png',
						key: 3,
					},
					{
						name: '分享给朋友',
						icon: '../../static/share.png',
						key: 4,
					},
					{
							name: '联系商家',
							icon: '../../static/contact.png',
							key: 5,
						},
					{
						name: '关于我们',
						icon: '../../static/fumou-center-template/10.png',
						key: 6,
					}

				]
			};
		},
		onShow() {
			this.account = JSON.parse(uni.getStorageSync('currentUser')).account
			this.avatar=JSON.parse(uni.getStorageSync('currentUser')).avatar
			this.$u.get('/users/getuserbyaccount?account='+this.account).then(res=>{
				this.nickname=res.data.user.nickname
				uni.getStorageSync('currentUser',JSON.stringify(res.data.user))
				if(res.data.user.avatar!=this.avatar){
					this.avatar=res.data.user.avatar
					
				}
			})
			// this.nickname = JSON.parse(uni.getStorageSync('currentUser')).nickname
			// this.avatar=JSON.parse(uni.getStorageSync('currentUser')).avatar
			// this.$u.get('/users/getuserbyaccount?account='+this.account).then(res=>{
			// 	this.avatar=res.data.user.avatar
			// })
			this.getBadge()
		},
		created() {
			this.getid()
		},
		methods: {
			closepop(){
				this.adviceparam.advice=''
			},
			getid(){
				this.$u.post('/baseinfo/getBaseinfo').then(res=>{
					this.id=res.data.baseinfolist._id
					console.log(this.id,'获取id');
				})
			},
			submit(){
				this.adviceparam.useraccount=this.account
				this.$u.post('/baseinfo/addBaseInfo',{onepiece:this.adviceparam,type:'addadvice',id:this.id}).then(res=>{
					this.show=false
					this.$refs.uToast.show({
						title: '反馈成功',
						type: 'success',
						duration: "500"
					})
				})
			},
			gomenu(index){
				if(index==5){
					// uni.navigateTo({
					// 	url: './orderstep',
					// 	animationType: 'pop-in',
					// 	animationDuration: 200
					// })
					uni.makePhoneCall({
						phoneNumber:'1234567890'
					})
				}else if(index==1){
					uni.navigateTo({
						url: './orderhistory',
						animationType: 'pop-in',
						animationDuration: 200
					})
					
				}else if(index==2){
					uni.navigateTo({
						url: './mycomment',
						animationType: 'pop-in',
						animationDuration: 200
					})
					
				}else if(index==4){
					uni.shareWithSystem({
					  summary: '快来使用点餐app吧,点击链接下载体验吧',
					  href: 'https://uniapp.dcloud.io',
					  success(){
					    // 分享完成，请注意此时不一定是成功分享
					  },
					  fail(){
					    // 分享失败
					  }
					})
					
				}else if(index==3){
					this.show=true
				}
			},
			getBadge(){
				this.$u.post('/order/getBadge',{useraccount:this.account}).then(res=>{
					this.badgelist=res.data.msg
					console.log(res,'获取卉鳌');
				})
			},
			navtoorder(key){
				uni.navigateTo({
					url: './order?key='+key,
					animationType: 'pop-in',
					animationDuration: 200
				})
			},
			gotoseeting(){
				uni.navigateTo({
					url: './setting',
					animationType: 'pop-in',
					animationDuration: 200
				})
			}
			

		},
		computed: {

		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.profily,
	.profily_header {
		border-radius: 8px;
	}

	.center {
		height: 100%;

		&_top {
			height: 18%;
			background: url('../../static/fumou-center-template/header.jpg') no-repeat 0% 50%;
			background-size: cover;

			// background: #E6E6E6;
			.mask {
				background: rgba(0, 0, 0, .4);
				height: 100%;
			}
		}

		&_box_bg {
			background: #F9F9F9;
			position: relative;

			.profily {
				position: absolute;
				width: 90%;
				// border:1px solid #F7F7F7;
				margin: 0 auto;
				top: -100upx;
				left: 5%;
				background: #FEFEFE;
				padding: 35upx;
				box-sizing: border-box;
				box-shadow: 0px 2px 5px #EDEDED;
			}
		}
	}

	.base {
		display: flex;
		align-items: center;
		border-bottom: 2px solid #F6F6F6;
		padding-bottom: 35upx;
		position: relative;

		.profily_header {
			height: 120upx;
			width: 120upx;
		}

		text {
			margin-left: 20px;
			font-size: 30upx;
		}

		image {
			position: absolute;
			height: 40upx;
			width: 40upx;
			right: 0px;
			top: 0px;
		}
	}

	.order_status {
		display: flex;
		justify-content: space-between;
		margin-top: 35upx;

		.status {
			width: 140upx;
			font-size: 24upx;
			text-align: center;
			letter-spacing: .5px;
			display: flex;
			flex-direction: column;

			.icon {
				width: 50upx;
				height: 50upx;
				margin: 0 auto;
				margin-bottom: 5px;

			}
		}
	}

	.baiban {
		background: #FEFEFE;
		height: 300upx;
	}

	.center_menu {
		width: 100%;
		display: inline-block;

		.menu_item {
			font-size: 28upx;
			letter-spacing: 1px;
			padding: 14px 5%;
			background: #FEFEFE;
			overflow: hidden;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			position: relative;
			border-bottom: 1px solid #EFEFEF;

			&:hover {
				background: #F6F6F6 !important;
			}

			&::after {
				content: '';
				width: 30upx;
				height: 30upx;
				position: absolute;
				right: 5%;
				background: url('../../static/fumou-center-template/right.png') no-repeat;
				background-size: 100%;
			}

			text:nth-of-type(1) {
				margin-left: 10px;
			}

			image {
				width: 40upx;
				height: 40upx;
			}

			&:nth-of-type(4) {
				margin-top: 10px;
			}
		}
	}
</style>
<!-- -->
